import math

def max_subset_split(arr):
    sum_total = sum(arr)
    n = len(arr)
    
    if sum_total == 0:
        if all(x == 0 for x in arr):
            return n
        else:
            for m in range(n, 0, -1):
                arr_sorted = sorted(arr, reverse=True)
                visited = [False] * n
                target = 0
                
                def backtrack(start, k, current_sum, count):
                    if k == 0:
                        return count == n
                    if current_sum == target:
                        if backtrack(0, k-1, 0, count):
                            return True
                        return False
                    for i in range(start, n):
                        if not visited[i]:
                            if current_sum + arr_sorted[i] <= target:
                                visited[i] = True
                                if backtrack(i+1, k, current_sum + arr_sorted[i], count + 1):
                                    return True
                                visited[i] = False
                    return False
                
                if backtrack(0, m, 0, 0):
                    return m
            return 1
    else:
        factors = set()
        for i in range(1, int(math.isqrt(sum_total)) + 1):
            if sum_total % i == 0:
                factors.add(i)
                factors.add(sum_total // i)
        
        possible_ms = sorted([m for m in factors if m <= n], reverse=True)
        
        for m in possible_ms:
            if m == 0:
                continue
            if sum_total % m != 0:
                continue
            target = sum_total // m
            arr_sorted = sorted(arr, reverse=True)
            visited = [False] * n
            
            def backtrack(start, k, current_sum):
                if k == 1:
                    return True
                if current_sum == target:
                    return backtrack(0, k-1, 0)
                for i in range(start, n):
                    if not visited[i] and (current_sum + arr_sorted[i]) <= target:
                        visited[i] = True
                        if backtrack(i+1, k, current_sum + arr_sorted[i]):
                            return True
                        visited[i] = False
                return False
            
            if backtrack(0, m, 0):
                return m
        return 1


# 测试用例
if __name__ == "__main__":    
    # 测试用例
    test_cases = [
        [6, 4, 3, 3, 2],
        [10, 8, 6, 4, 2],
        [7, 7, 7],
        [5, 4, 3, 2, 1],
        [5, 4, 3, 2],
    ]
    
    for i, test in enumerate(test_cases):
        print(f"测试用例 {i+1} {test}: 最大的m值为 {max_subset_split(test)}")